!function ($) {
    var setter = {
        container:'LAY_app' //index页面容器
        ,MOD_NAME: 'admin'
        ,pageTabs: true
    }
        ,g="layui-icon-shrink-right" //侧边栏伸缩 展开
        ,m="LAY_app_flexible"
        ,u = $("#" + setter.container)
        ,v="layadmin-side-spread-sm"
        ,x="layui-icon-spread-left" //侧边栏伸缩 隐藏
        ,C="layadmin-side-shrink"
        ,M='LAY-system-side-menu'
        ,s="#LAY_app_body"
    //todo： begin base64加密解密
        ,_keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
        ,r=$(window)
        ,_F = {
        // 全屏
        fullscreen:function (e) {
            let SCREEN_FULL = 'layui-icon-screen-full'
                ,SCREEN_REST = 'layui-icon-screen-restore'
                ,iconElem = e.children("i");
            if (iconElem.hasClass(SCREEN_FULL)){
                let elem = document.body;
                if (elem.webkitRequestFullScreen){
                    elem.webkitRequestFullScreen();
                } else if (elem.mozRequestFullScreen){
                    elem.mozRequestFullScreen();
                }else if (elem.requestFullscreen) {
                    elem.requestFullscreen();
                }
                iconElem.addClass(SCREEN_REST).removeClass(SCREEN_FULL);
            } else {
                let elem = document;
                if (elem.webkitCancelFullScreen) {
                    elem.webkitCancelFullScreen();
                } else if (elem.mozCancelFullScreen) {
                    elem.mozCancelFullScreen();
                } else if (elem.cancelFullScreen) {
                    elem.cancelFullScreen();
                } else if (elem.exitFullScreen) {
                    elem.exitFullscreen();
                }
                iconElem.addClass(SCREEN_FULL).removeClass(SCREEN_REST);
            }
        },
        // 侧边栏伸缩
        flexible:function (e) {
            let a=e.find("#"+m),
                i=a.hasClass(x);
            _F.sideFlexible(i?"spread":null);
        },
        sideFlexible:function(e){
            let i=u,t=$("#"+m),n=_F.screen();
            "spread"===e?(t.removeClass(x).addClass(g),n<2?i.addClass(v):i.removeClass(v),i.removeClass(C)):(t.removeClass(g).addClass(x),n<2?i.removeClass(C):i.addClass(C),i.removeClass(v))
        },
        screen:function(){
            let e=$(window).width();
            return e>=1200?3:e>=992?2:e>=768?1:0
        },
        //定义一组打开元素动作
        open:function(n,e){
            // get 菜单栏高亮提示框 span元素
            let _e1 = $(this)
                ,_span = $('#' + M).children('span.layui-nav-bar').length
                ,getMenuLightSpan = function (top) {
                return '<span class="layui-nav-bar" style="top:' + top + 'px;height:40px;opacity: 1;"></span>'
            }
                ,callback = function (i) {
                if (i != null && _span < 1){
                    let _style = getMenuLightSpan(i);
                    $('#' + M).append(_style);
                }else {
                    $('#' + M).children('span.layui-nav-bar').css('top',i + 'px');
                }
            };
            if (n=='mouseenter'&&e == 'lay-tips') {
                let i = _e1.parent().hasClass("layui-nav-item")&&(_e1.parent().parent()[0].tagName=='UL'||_e1.parent().parent()[0].tagName=='ul')?_e1.parent().position().top:null;
                callback(i);
            }else if (n=='nav-menu-mouseenter'&&e == 'lay-href') {
                let _e = $('#LAY-system-side-menu').find('li.layui-nav-itemed')
                    ,_isItemed = _e.hasClass('layui-nav-itemed');
                if (_isItemed){
                    let i = _e.position().top;
                    callback(i);
                }
            }
        },
        close:function(n,e){
            let _e = a(this)
                ,_index = $('ul#LAY-system-side-menu li').index(_e.parent('li'));
            if (n=='mouseleave'&&e == 'lay-tips'){
                _e.parent().hasClass("layui-nav-item")&&(_e.parent().parent()[0].tagName=='UL'||_e.parent().parent()[0].tagName=='ul')?_e.parent().parent().children('span.layui-nav-bar').remove():null;
            }
        },
        isEmpty:function(obj) {
            if(obj==null||obj==undefined||obj==""){
                return true;
            }
            return false;
        },
        isNotEmpty:function(obj) {
            return !_F['isEmpty'].call(this , obj);
        },
        menuTheme:function(menuAList){
            $.each(menuAList , function (index , value) {
                let flag = $(value).next('DL');
                if (flag.length > 0) {
                    $(value).append('<span class="layui-nav-more"></span>')
                }
            })
        },
        ajaxSubmit:function(type , url , jsonData , async , dataType){
            let msg = {
                status:1 ,
                data:null,
                msg:""
            } , defaultAsync = _F.isNotEmpty(async)?async:false , defaultDataType =  _F.isNotEmpty(dataType)?dataType:"JSON";
            $.ajax({
                type:type,
                url:url,
                data:jsonData,
                async:defaultAsync,
                dataType:defaultDataType,
                success:function (result) {
                    msg.status = result.status;
                    msg.data = result.data;
                    msg.msg = result.msg;
                },
                error:function () {

                }
            });
            return msg;
        },
        /**
         *开启form写保护，所有input只读，button隐藏,同时禁用input的onclick事件
         */
        formWriteProtect:function(){
            let inputList = $('input') , btnList = $("button");
            $.each(btnList , function (i , v) {
                let a = $(v).attr('lay-filter');
                if (a != 'cancel'){
                    $(v).attr("style","display:none;");
                }
            });
            $.each(inputList , function (i , v) {
                $(v).removeAttr("onclick");
                $(v).attr('readonly' , 'readonly');
            });
        },
        formButtonItem:function(formName , permission){
            let a = '<div class="layui-footer" style="left: 0;">\n' +
                '                                    <button type="button" class="layui-btn" shiro:hasPermission=' + permission + ' lay-submit lay-filter="' + formName + 'Save" onsubmit="return false" id="' + formName + 'SaveBtn" blue-form-id="' + formName + 'Form">立即提交</button>\n' +
                '                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>\n' +
                '                                    <button type="button" class="layui-btn layui-btn-primary" onsubmit="return false" id="' + formName + 'CancelBtn">关闭</button>\n' +
                '                                </div>';
            $(".blue-form-button-item").append(a);
        },
        /**
         * 该方法需要配合layui使用，页面加载时需声明layer变量
         */
        active:{
            closeWindow:function(index){
                parent.layer.close(index); //再执行关闭
            },
            showMsg:function(msg ){
                layer.confirm(msg, {
                    btn: ['关闭'] //按钮
                }, function(){
                    location.reload();
                    layer.closeAll();
                });
            },
            saveMsg: function(message , index){
                layer.confirm(message, {
                    btn: ['关闭'] //按钮
                }, function(){
                    window.parent.location.reload();
                    parent.layer.close(index); //再执行关闭
                });
            },
            ajaxFormSubmit:function(url , jsonData){
                let msg = "";
                $.ajax({
                    type:'POST',
                    url:url,
                    data:jsonData,
                    async:false,
                    dataType:'text',
                    success:function (data) {
                        msg = data;
                    },
                    error:function () {

                    }
                });
                return msg;
            },
            layerOpen:function(url , title , width , height){
                let _width = '60' , _height = '70';
                _width = _F.isNotEmpty(width)?width:_width;
                _height = _F.isNotEmpty(height)?height:_height;
                layer.open({
                    type: 2,
                    title: title,
                    shade: false,
                    maxmin: true,
                    area: [_width + '%', _height + '%'],
                    content: url
                });
            },
            /**
             * 调用页面 必须声明 table = layui.table,并通过参数传入
             * @param e
             * @param limit
             * @param cols
             */
            layTable:function (table , e , limit , cols , tableId , extendRequest) {
                let formId = $(e).attr("blue-form-id")
                    ,formData = $("#" + formId).serialize()
                    ,formUrl = $("#" + formId).attr("action") + "?" + formData;
                if (_F.isNotEmpty(extendRequest)){
                    formUrl = formUrl + "&" + extendRequest;
                }
                table.render({
                    elem: '#' + tableId
                    ,url:formUrl
                    ,limit: limit
                    ,page: true
                    ,parseData: function(res) { //res 即为原始返回的数据
                        return {
                            "code": 0, //解析接口状态
                            "msg": '', //解析提示文本
                            "count": res.total, //解析数据长度
                            "data": res.records //解析数据列表
                        };
                    }
                    ,cols:cols
                });
            },
            /**
             * 获取后端table数据
             * @param e
             * @param extendRequest
             * @returns {[]}
             */
            getPageData:function (e , extendRequest) {
                let formId = $(e).attr("blue-form-id")
                    ,formData = $("#" + formId).serialize()
                    ,formUrl = $("#" + formId).attr("action") + "?" + formData;
                if (_F.isNotEmpty(extendRequest)){
                    formUrl = formUrl + "&" + extendRequest;
                }
                let msg = [];
                $.ajax({
                    type:'POST',
                    url:formUrl,
                    async:false,
                    dataType:'JSON',
                    success:function (data) {
                        msg = data.records;
                    },
                    error:function () {

                    }
                });
                return msg;
            },
            /**
             *
             */
            tableWriteProtect:function(table , tableId , tableData , cols , isSafe){
                if (isSafe){
                    $.each(cols[0] , function (i , v) {
                        v.edit = false;
                    });
                }
                table.render({
                    elem: '#' + tableId
                    ,data:tableData
                    ,cols:cols
                    ,page:true
                    ,limit:tableData.length
                });
            },
            /**
             * table中的可编辑单元格自动触发单击事件
             * @param tableId
             * @param dataIndex         行号
             * @param clickFieldName    点击字段名称
             */
            tableColClick:function (tableId , dataIndex , clickFieldName) {
                let trs = $("#" + tableId).next().find(".layui-table-main").find("table tbody tr");
                if (trs.length > 0){
                    $.each(trs , function (index , value) {
                        let _dataIndex = $(value).attr("data-index");
                        if (_dataIndex == dataIndex){
                            let tds = $(value).find("td");
                            $.each(tds , function (i , v) {
                                let data_field = $(v).attr("data-field");
                                if (data_field == clickFieldName){
                                    v.click();
                                }
                            })
                        }
                    });
                }
            },
            /**
             * 给table动态增加 N个  空白行
             * @param table
             * @param tableId
             * @param templateData      数据模板
             * @param rowCount          增加的行数
             * @param isClick           是否触发鼠标单击事件
             * @param clickFieldName    需要单击的field名称，需要isClick = true，并且该列为可编辑
             */
            tableAddRow:function (table , tableId , templateData , rowCount , isClick , clickFieldName) {
                let tableDataList = table.cache[tableId];
                let dataIndex = _F.isEmpty(tableDataList.length)?0:tableDataList.length;
                for (let i = dataIndex; i < (dataIndex + rowCount); i++) {
                    let _data = {
                        LAY_TABLE_INDEX:i
                    };
                    $.extend(_data , templateData);
                    tableDataList.push(_data);
                }
                // todo:2022.08.01:修复了表格重载时不更新分页的问题
                table.reload(tableId , {
                    data:tableDataList
                    ,page:true
                    ,limit:tableDataList.length
                    ,limits:[tableDataList.length]
                } , true);
                if (isClick == true){
                    _F.active.tableColClick(tableId , dataIndex , clickFieldName);
                }
            },
            /**
             * 返回一个 key:value 的对象，key是table中的标题明细
             * @param object
             * @returns {{}}
             */
            mapCloneKey:function (object) {
                let temp = {};
                $.each(object , function (i , v) {
                    temp[v.field] = "";
                });
                return temp;
            },
            tableColUpdate:function (table , tableId , rowIndex , colName , colValue) {
                table.cache[tableId][rowIndex][colName] = colValue;
            },
            tableRowUpdate:function (table , tableId , rowIndex , Object) {
                $.extend(table.cache[tableId][rowIndex] , Object);
            },
            tableReload:function (table , tableId) {
                let tableDataList = table.cache[tableId];
                table.reload(tableId , {
                    data:tableDataList
                    ,limit:tableDataList.length
                });
            }
        },
        //todo:未完成，待定
        openTabsPage:function(_herf,_titile){
            /*                    let b=a("#LAY_app_tabsheader>li"),y=_herf.replace(/(^http(s*):)|(\?[\s\S]*$)/g,"")
                                    ,t=tabsPage;
                                if(b.each(function(e){
                                    let i=a(this),n=i.attr("lay-id");
                                    n===_a&&(t.index=e)
                                }),_titile=_titile||"新标签页")
                                    (r(s).append(['<div class="layadmin-tabsbody-item layui-show">','<iframe src="'+a+'" frameborder="0" class="layadmin-iframe"></iframe>',"</div>"].join("")),
                                        t.index=b.length,i.tabAdd(o,{title:"<span>"+d+"</span>",id:a,attr:y}));
                                else{
                                    let u=n.tabsBody(n.tabsPage.index).find(".layadmin-iframe");u[0].contentWindow.location.href=a
                                }
                                i.tabChange(o,a),n.tabsBodyChange(t.index,{url:a,text:d})*/
        },
        formSerialize:function(e){
            return $("#" + e).serialize();
        },
        formSubmit:function (e) {
            let formId = $(e).attr("blue-form-id")
                ,formData = _F.formSerialize(formId)
                // $("#" + formId).serialize()
                ,formUrl = $("#" + formId).attr("action")
                ,msg = '';
            $.ajax({
                type:'POST',
                url:formUrl,
                data:formData,
                async:false,
                dataType:'text',
                success:function (data) {
                    msg = data;
                },
                error:function () {

                }
            });
            return msg;
        },
        showIndex:function(isSystem , entityName){
            if (isSystem == true || isSystem == 'true'){
                $("#" + entityName + "-tree-index").css("display","block");
                $("#" + entityName + "-panel").removeClass();
                $("#" + entityName + "-panel").addClass("layui-col-md10");
            }else {
                $("#" + entityName + "-tree-index").css("display","none");
                $("#" + entityName + "-panel").removeClass();
                $("#" + entityName + "-panel").addClass("layui-col-md12");
            }
        },
        createMenu:function(treeData , container){
            let root = [] , nodes = {};
            // 转换treeData的json数据
            /**
             * pId = 0 存入root，其他存入nodes
             */
            $.each(treeData , function (i , v) {
                if (v.pId == '0'){
                    root.push(v);
                }else {
                    let indexCount = 0;
                    for (key in nodes){
                        if (key == v.pId){
                            nodes[key].push(v);
                            indexCount = indexCount + 1;
                        }
                    }
                    if (indexCount == 0){
                        nodes[v.pId] = [v];
                    }
                }
            });
            // 遍历root数组，生成菜单
            $.each(root , function (i , v) {
                let rootEl = '';
                // 如果 treeData中的menuHref 为空，则调用getChildren方法遍历
                if (v.menuHref == '' || v.menuHref == undefined || v.menuHref == 'undefined'){
                    let isChecked = '';
                    if (i == 0){
                        isChecked = 'layui-nav-itemed';
                    }
                    rootEl = rootEl + '<li data-name="' + v.name + '" class="layui-nav-item ' + isChecked + '"><a href="javascript:;" lay-tips="' + v.name + '" lay-direction="2">';
                    rootEl = rootEl + '<i class="layui-icon ' + v.menuIcon +'"></i>';
                    rootEl = rootEl + '                    <cite>' + v.name + '</cite></a>';
                    rootEl = rootEl + getChildren(v.id , nodes);
                    rootEl = rootEl + "</li>";
                }else {
                    rootEl = rootEl + '<li data-name="' + v.name +'" class="layui-nav-item"><a href="javascript:;" lay-href="' + v.menuHref+ '" lay-tips="' + v.name + '" lay-direction="2">';
                    rootEl = rootEl + '<i class="layui-icon ' + v.menuIcon +'"></i>';
                    rootEl = rootEl + '                    <cite>' + v.name + '</cite></a>';
                    rootEl = rootEl + "</li>";
                }

                $("#" + container).append(rootEl);
            });

            function getChildren(pId , data) {
                let ulElStart = '<dl class="layui-nav-child">', ulElEnd = '</dl>';
                let liElStart = '';
                for (key in data){
                    if (key == pId){
                        let nodeList = nodes[key];
                        $.each(nodeList , function (i , v) {
                            if (v.menuHref == '' || v.menuHref == undefined || v.menuHref == 'undefined') {
                                let isChecked = '';
                                if (i == 0){
                                    isChecked = 'layui-nav-itemed';
                                }
                                liElStart = liElStart + '<dd data-name="' + v.name + '"><a href="javascript:;" lay-tips="' + v.name + '" lay-direction="2">' + v.name + '</a>';
                                liElStart = liElStart + getChildren(v.id , nodes);
                                liElStart = liElStart + "</dd>";
                            }else {
                                liElStart = liElStart + '<dd data-name="' + v.name + '"><a lay-href="' + v.menuHref + '">' + v.name + '</a></dd>';
                            }
                        });
                    }
                }
                return liElStart == '' || liElStart == undefined?'':ulElStart + liElStart + ulElEnd;
            };
        },
        clone: function (obj) {
            if (obj === null) return null;
            var o = _F.isArray(obj) ? [] : {};
            for (var i in obj) {
                o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? _F.clone(obj[i]) : obj[i]);
            }
            return o;
        },
        isArray: function (arr) {
            return Object.prototype.toString.apply(arr) === "[object Array]";
        },
        refresh:function () {
            setTimeout('window.location.reload()',0);
        },
        base64Encode:function(str){
            let output = "",chr1, chr2, chr3, enc1, enc2, enc3, enc4;
            let i = 0;
            str = _F.utf8ToEnCode(str);
            while (i < str.length){
                chr1 = str.charCodeAt(i++);
                chr2 = str.charCodeAt(i++);
                chr3 = str.charCodeAt(i++);
                enc1 = chr1 >> 2;
                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                enc4 = chr3 & 63;
                if (isNaN(chr2)) {
                    enc3 = enc4 = 64;
                } else if (isNaN(chr3)) {
                    enc4 = 64;
                }
                output = output +
                    _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
                    _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
            }
            return output;
        },
        base64Decode:function(str){
            let output = "", chr1, chr2, chr3,enc1, enc2, enc3, enc4;
            let i = 0;
            str = str.replace(/[^A-Za-z0-9\+\/\=]/g, "");
            while (i < str.length) {
                enc1 = _keyStr.indexOf(str.charAt(i++));
                enc2 = _keyStr.indexOf(str.charAt(i++));
                enc3 = _keyStr.indexOf(str.charAt(i++));
                enc4 = _keyStr.indexOf(str.charAt(i++));
                chr1 = (enc1 << 2) | (enc2 >> 4);
                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
                chr3 = ((enc3 & 3) << 6) | enc4;
                output = output + String.fromCharCode(chr1);
                if (enc3 != 64) {
                    output = output + String.fromCharCode(chr2);
                }
                if (enc4 != 64) {
                    output = output + String.fromCharCode(chr3);
                }
            }
            output = _F.utf8ToDeCode(output);
            return output;
        },
        utf8ToEnCode:function (str) {
            str = str.replace(/\r\n/g,"\n");
            let utfText = "";
            for (let i = 0 ;i < str.length;i++){
                let char = str.charCodeAt(i);
                if (char < 128){
                    utfText += String.fromCharCode(char);
                }else if ((char > 127) && (char < 2048)){
                    utfText += String.fromCharCode((char >> 6) | 192);
                    utfText += String.fromCharCode((char & 63) | 128);
                }else {
                    utfText += String.fromCharCode((char >> 12) | 224);
                    utfText += String.fromCharCode(((char >> 6) & 63) | 128);
                    utfText += String.fromCharCode((char & 63) | 128);
                }
            }
            return utfText;
        },
        utf8ToDeCode:function (str) {
            let string = "";
            let i = 0;
            var c = c1 = c2 = 0;
            while ( i < str.length ) {
                c = str.charCodeAt(i);
                if (c < 128) {
                    string += String.fromCharCode(c);
                    i++;
                } else if((c > 191) && (c < 224)) {
                    c2 = str.charCodeAt(i+1);
                    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                    i += 2;
                } else {
                    c2 = str.charCodeAt(i+1);
                    c3 = str.charCodeAt(i+2);
                    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                    i += 3;
                }
            }
            return string;
        }
    }
        ,_zTreeTool = {
        defaultOption:{
            treeId:'',
            searchBtnId:'searchBtn',
            searchInputId:'searchInput',
            titleId:'',
            title:'',   //zTree页面 title
            url:'',     //nodes 请求地址
            echoId:'',  //回显元素id
            excludeCode:'', //排除节点ID
            /**
             * 展开 / 折叠 全部节点

             此方法不会触发 beforeExpand / onExpand 和 beforeCollapse / onCollapse 事件回调函数。

             请通过 zTree 对象执行此方法。
             */
            isExpandAll:false,
            isShowCode:'false',   //是否显示节点代码 默认不显示
            canSelectRoot:false,     //根节点 是否允许选择，默认可选
            canSelectParent:true,    //父节点 是否允许选择，默认可选
            setting:{
                check: {
                    autoCheckTrigger: true,
                    enable: false,//checkbox
                    chkStyle: "checkbox",
                    chkboxType: {"Y": "ps", "N": "ps"}
                },
                view: {
                    nameIsHTML: true, //允许name支持html
                    selectedMulti: false
                },
                edit: {
                    enable: false,
                    editNameSelectAll: false
                },
                // zTree data格式定义
                data: {
                    keep: {
                        leaf: true,
                        parent: true
                    },
                    key: {
                        isParent: "isParent",
                        checked: "isChecked"
                    },
                    simpleData: {
                        enable: true,
                        idKey: "id",
                        pIdKey: "pId",
                        rootPid: "0"
                    }
                }
            },
            extendData:""
        }
        ,nodes:[],treeObj:'',
        setOption:function (uo) {
            _zTreeTool.option = {};
            _zTreeTool.option = _F.clone(_zTreeTool.defaultOption);
            _zTreeTool.option = $.extend(true , _zTreeTool.option , uo);
        },
        destroy:function(uo){
            $.fn.zTree.destroy(uo.treeId);
        },
        getOption:function () {
            return _zTreeTool.option;
        },
        setNodes:function () {
            let userOption = _zTreeTool.getOption()
                ,excludeCode = _F.isNotEmpty(userOption.excludeCode)?"excludeCode=" + $("#" + userOption.excludeCode).val():''
                ,isShowCode = "isShowCode=" + userOption.isShowCode
                ,extendData = userOption.extendData
                ,url = userOption.url + '?' + isShowCode;
            if (_F.isNotEmpty(excludeCode)){
                url = url + "&" + excludeCode;
            }
            $.ajax({
                type:'get',
                url:url,
                data:extendData,
                dataType:'json',
                async:false,
                success:function (result) {
                    if (_F.isNotEmpty(result)) {
                        _zTreeTool.nodes = result.concat();
                    }
                },
                error:function () {

                }
            });
        },
        getNodes:function () {
            return _zTreeTool.nodes;
        },
        setTreeObj:function(isExpandAll){
            let treeId = _zTreeTool.option.treeId
                ,expand = isExpandAll;
            _zTreeTool.treeObj = $.fn.zTree.getZTreeObj(treeId);
            _zTreeTool.treeObj.expandAll(expand);
        },
        getTreeObj:function(treeId){
            return $.fn.zTree.getZTreeObj(treeId);
        },
        /**
         * zTree 用户入口
         * @param zTreeID           zTree id
         * @param uo                用户option
         * @param searchBtnID       zTree模糊查询 按  键id
         * @param searchInputID     zTree模糊查询 输入框id
         */
        loadTree:function (uo) {
            _zTreeTool.setOption(uo);
            // _zTreeTool.destroy(uo);
            _zTreeTool.setNodes();
            let zTreeNodes = _zTreeTool.getNodes()
                ,userSetting = _zTreeTool.option.setting;
            /*$("#" + _zTreeTool.option.searchBtnId).on("click" , function () {
                _F.fuzzSearch(_zTreeTool.option.treeId,'#' + _zTreeTool.option.searchInputId,null,true); //初始化模糊搜索方法
            });*/
            $.fn.zTree.init($("#" + _zTreeTool.option.treeId), userSetting, zTreeNodes);
            _zTreeTool.setTreeObj(_zTreeTool.option.isExpandAll);
        },
        //打开zTree弹层
        openTreeLay:function (uo , _w , _h) {
            _zTreeTool.setOption(uo);
            let _uo = _zTreeTool.getOption(),titleId = _F.isNotEmpty(_uo.titleId)?_uo.titleId:'',title = _F.isNotEmpty(_uo.title)?_uo.title:'';
            if (_F.isNotEmpty(titleId) && _F.isNotEmpty(title)){
                $("#" + titleId).empty();
                $("#" + titleId).append(title);
            }
            _zTreeTool.loadTree(_uo);
            let _top = _h * 0.2
                ,_left = _w * 0.2;
            $(".modal-bg").css({"display":"block" , "width":_w , "height":_h});
            $(".modal-show").css({"display":"block"}) ;
        },
        //关闭zTree弹层
        closeTreeLay:function () {
            $(".modal-bg").css("display" , "none");
            $(".modal-show").css("display" , "none");
        },
        getNewTreeAttribute:function(uo , treeNodeId , isParent){
            let excludeCode = ''
                ,url = uo.url.replace("treeData" , "createNextNode");
            if (isParent && _F.isNotEmpty(uo.excludeCode)){
                excludeCode = $("#" + uo.excludeCode , window.parent.document).val();
            }else if (!isParent && _F.isNotEmpty(uo.excludeCode)){
                excludeCode = $("#" + uo.excludeCode).val();
            }
            let data = {parentCode:treeNodeId,id:excludeCode};
            let msg ;
            $.ajax({
                type:'POST',
                url:url,
                dataType:'JSON',
                cache:false,
                headers:{
                    'Content-Type' : 'application/json;charset=utf-8'
                },
                data:JSON.stringify(data),
                async:false,
                success:function (result) {
                    msg = result;
                },
                error:function () {

                }
            });
            return msg;
        },
        updateTreeAttribute:function (uo , parentCode) {
            let excludeCode = _F.isNotEmpty(uo.excludeCode)?$("#" + uo.excludeCode).val():''
                ,data = {parentCode:parentCode,id:excludeCode}
                ,url = uo.url.replace("treeData" , "createNextNode");
            $.ajax({
                type:'POST',
                url:url,
                dataType:'JSON',
                cache:false,
                headers:{
                    'Content-Type' : 'application/json;charset=utf-8'
                },
                data:JSON.stringify(data),
                success:function (result) {
                    let _treeSort = result.treeSort
                        ,_treeCode = result.treeCode;
                    _F.isNotEmpty($("#treeSort"))?$("#treeSort").val(_treeSort):null;
                    _F.isNotEmpty($("#treeCode"))?$("#treeCode").val(_treeCode):null;
                },
                error:function () {

                }
            });
        }
    };

    $.fn.blueJs = {
        /*start:function () {
            let o = $('body')
                ,F = _F

                ,n={
                modules:{},status:{},timeout:10,event:{}
            }
                ,tabsPage={}
                ,menuAList = $('#' + M).find('a');
            // todo:以下内容暂不开发
            //todo: index页面打开时，为左侧菜单栏添加右侧图标，此处调用是为了测试，正确的调用方式是：菜单初始化完成后再调用
            F.menuTheme(menuAList);
            /!**
             * 鼠标点击事件
             * layadmin-event 标签中设定的事件，需在 F 中定义动作
             *!/
            o.on('click' , '*[layadmin-event]' , function () {
                let e = $(this) , i = e.attr('layadmin-event');
                F[i].call(this , e);
            });
            o.on('click' , '*[lay-href]' , function () {
                let e=$(this),i=e.attr("lay-href"),t=e.attr("lay-text");
                tabsPage.elem=e;
                F['openTabsPage'].call(this , i,t||e.text());

            });
            o.on('click' , 'a' ,function () {
                let e = $(this) , i = F['isEmpty'].call(this , e.attr('href'))?null:e.attr('href');
                if (i != null){
                    e.parent().hasClass("layui-nav-itemed")?e.parent().removeClass('layui-nav-itemed'):e.parent().addClass('layui-nav-itemed');
                }
            });
            /!**
             * 鼠标滑入事件
             *!/
            o.on("mouseenter","*[lay-tips]",function(){
                let e = $(this),i = e.attr('class');
                if (F['isNotEmpty'].call(this,i) && i == 'blue-left-menu-tree') {
                    F['open'].call(this ,'mouseenter', 'lay-tips');
                }
            });
            o.on('mouseenter','*[lay-href]',function () {
                let e = $(this),i = e.attr('class');
                if (F['isNotEmpty'].call(this,i) && i == 'blue-left-menu-tree') {
                    F['open'].call(this ,'nav-menu-mouseenter', 'lay-href');
                }
            })

        },*/
        tools:_F,
        zTreeTool:_zTreeTool
    };

}(jQuery);